@extends('admin.base')
@section('title', '拼团订单')
@section('content')
<div id="main">
 <div class="layui-card">
    <fieldset class="layui-elem-field">
        <div class="layui-field-box">
            <span class="layui-breadcrumb" lay-separator=">>">
                <a class="layui-btn-sm" href="{{url('admin/group/order')}}" style="cursor:pointer;" ><cite>拼团订单</cite></a>;
            </span>
        </div>
    </fieldset>
    <div class="layui-card-header">
      <div>
        <span class="pull-left">
          <div class="layui-form">
            <div class="layui-form-item">
              <div class="layui-inline" style="width:100%">     
                <label class="layui-form-label">商品ID</label>
                <div class="layui-input-inline" style="width:120px">
                    <input type="text" class="layui-input" id="" name="sub_gid" value="{{ isset($request['gid']) ? $request['gid'] : '' }}"  placeholder="请输入商品ID">
                </div>
                <label class="layui-form-label">商品名</label>
                <div class="layui-input-inline" style="width:120px">
                    <input type="text" class="layui-input" id="" name="sub_gname" value="{{ isset($request['gname']) ? $request['gname'] : '' }}"  placeholder="请输入商品名">
                </div>
                <div class="layui-inline">
                        <label class="layui-form-label">状态</label>
                        <div class="layui-input-inline">
                            <select name="sh_state" lay-verify="required">
                                <option value="0">请选择</option>
                                <option value="1" @if($request->state == 1) selected @endif>待发货</option>
                                <option value="2" @if($request->state == 2) selected @endif>待收货</option>
                                <option value="3" @if($request->state == 3) selected @endif>已完成</option>
                            </select>
                        </div>
                      </div>
                      <div class="layui-inline">
                        <label class="layui-form-label">时间</label>
                        <div class="layui-input-inline">
                            <input type="text" class="layui-input" class="jeinput" id="test11" placeholder="创建时间(年月日~年月日)"
                                   name="month" value="{{ isset($request->month) ? $request->month : '' }}" readonly>
                        </div>
                        </div>
              
                <button class="layui-btn" lay-submit lay-filter="selectsub" style="margin-bottom:10px">搜索</button>
              </div>
            </div>
          </div>
        </span>
      </div>
    </div>

    <div class="layui-card-body">
        <style>
            table tr td.tc,table tr th.tc {
                text-align: center;
                cursor:default;
            }
        </style>
        <table class="layui-table" lay-even lay-size="">
            <colgroup>
                <col width="">
                <col width="">
                <col width="">
                <col width="">
                <col width="">
                <col width="">
            </colgroup>
            <thead>
                <tr>
                    <th class="tc">ID</th>
                    <th class="tc">订单编号</th>
                    <th class="tc">中奖商品</th>
                    <th class="tc">商品图片</th>
                    <th class="tc">规格</th>
                    <th class="tc">价格</th>
                    <th class="tc">中奖号</th>
                    <th class="tc">中奖批次</th>
                    <th class="tc">支付方式</th>
                    <th class="tc">收货人</th>
                    <th class="tc">联系方式</th>
                    <th class="tc">收货地址</th>
                    <th class="tc">快递公司</th>
                    <th class="tc">快递单号</th>
                    <th class="tc">发货状态</th>
                    <th class="tc">创建时间</th>
                    <th class="tc">操作</th>
                </tr>
                <tbody>
                    @if($list->isEmpty())
                        <tr>
                            <td colspan="19" class="tc">暂无数据</td>
                        </tr>
                    @else
                        @foreach ($list as $v)
                           <tr>
                            
                                <td class="tc">{{$v['id']}}</td>
                                <td class="tc">{{$v['sn']}}</td>
                                <td class="tc">{{$v['gname']}}</td>
                                <td class="tc">
                                    <img src="{{$v['gpic']}}" height="100px">
                                </td>
                               <td class="tc">{{ $v['attr'] }}</td>
                                <td class="tc">{{ $v['sell'] }}</td>
                                <td class="tc">{{ $v['num'] }}</td>
                                <td class="tc">{{ $v['curcle'] }}</td>
                                <td class="tc">{{ $v['paytypename'] }}</td>
                                <td class="tc">{{ $v['linkman'] }}</td>
                                <td class="tc">{{ $v['linktel'] }}</td>
                                <td class="tc">{{ $v['address'] }}</td>
                                <td class="tc">{{ $v['express_com'] }}</td>
                                <td class="tc">{{ $v['express_num'] }}</td>

                                <td class="tc">@if($v['status'] ==1)待发货
                                    @elseif($v['status'] ==2)待收货
                                    @elseif($v['status'] ==3)已完成
                                    @elseif($v['status'] ==0)无
                                    @endif</td>
                                <td class="tc">{{ $v['created_at'] }}</td>
                            
                                <td class="tc">
                                @if($v['status'] == 1)
                                     <button class="layui-btn layui-btn-sm"
                                                onclick="active('{{url('admin/group/send_ok')}}','{{$v->id}}','请输入快递信息');">发货
                                        </button>
                                @else
                                    <button class="layui-btn layui-btn-disabled">
                                        无
                                    </button>
                                @endif
                               
                                </td>
                            </tr>
                        @endforeach
                    @endif
                </tbody>
            </thead>
        </table>
        <!-- 分页 -->
        <div class="sabrosus" >{{ $list->appends(['gid'=>$request['gid'],'gname'=>$request['gname'],'month'=>$request['month']])->links() }}</div>
    </div>

 </div>
 </div>
@endsection
@section('js')
    <script>
        // 删除按钮事件 -- 弹出删除层
        var config = function(url,id,state,title){
            layer.confirm('确定更改('+title+')！', {
                btn: ['确定','取消'] //按钮
            },function(){
                $.post(url,{
                    id: id,state:state,
                },function(data){
                    console.log(data);
                    layer.msg(data.msg);
                    // if(data.code == 1){
                    //     layer.msg('更改成功！');
                    // }else{
                    //     layer.msg('更改失败！');
                    // }
                    location.href = location.href;
                });
            });
        }


        layui.use(['form','laydate'], function(){
            var form = layui.form;
            var laydate = layui.laydate;
            form.render();

            //搜索
            form.on('submit(selectsub)', function(data){
                var gid = $("input[name=sub_gid]").val();
                var gname = $("input[name=sub_gname]").val();
                var month = $("input[name=month]").val();
                var state = $("select[name=sh_state]").val();
                location.href = "{{url('admin/group/order')}}"+"?gid=" + gid+ '&gname='+gname+'&month='+month+'&state='+state;
                return false;
            });

            //日期时间选择器
            laydate.render({ 
                elem: '#test1'
                ,type: 'datetime'
            });


            //监听指定开关
            form.on('switch(switchCy)', function(data){
                var id = data.value;

                if(data.elem.checked){
                    var state = 1;//启用
                }else{
                    var state = 2;//禁用               
                }
                ajax('/admin/group/up_state',{id:id,state:state});
            });
        });
    </script>
@endsection